package com.cet.designpatterns.singleton.type6;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @program: algorithm
 * @description: 懒汉式（线程安全,双重检查，推荐）
 * @author: 陈恩涛
 * @create: 2021-08-30 23:17
 **/
public class SingletonTest {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Singleton instance = Singleton.getInstance();
        Constructor<Singleton> dc = Singleton.class.getDeclaredConstructor(null);
        dc.setAccessible(true);
        Singleton instance1 = dc.newInstance();
        System.out.println(instance);
        System.out.println(instance1);
    }
}
